/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * mainWin.java
 *
 * Created on Nov 19, 2009, 4:11:04 PM
 */

package desktopapplication1;


import BackEnd.Categoria;
import BackEnd.Producto;
import BackEnd.SubCategoria;
import BackEnd.User;
import Services.Catalog;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.WindowEvent;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;

import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.ApplicationContext;

/**
 *
 * @author ign
 */
public class mainWin extends javax.swing.JFrame {

    public static User user;
    private static  ArrayList<Producto> prods;
    private static ArrayList<Categoria> categorias;
    private static ArrayList<SubCategoria> subCategorias;
    private static int currPage = 0;
    private static int cantPag = 0;
    DesktopApplication1 app;

    public static void setUser(User user){
        mainWin.user=user;
    }


    public static User getUser(){
        return user;
    }


    public static int getCatId(String name){
        for(Categoria cat:categorias){
            if(cat.getName().equals(name)){
                return cat.getId();
            }
        }
        return 0;
    }

    public static int getSubCatId(String name){
        for(SubCategoria scat:subCategorias){
            if(scat.getName().equals(name)){
                return scat.getId();
            }
        }
        return 0;
    }

    /** Creates new form mainWin */
    public mainWin() {
	initComponents();
	
    }

    /** Creates new form mainWin */
    public mainWin(DesktopApplication1 app) {
	initComponents();
	this.app = app;
    }

    public mainWin(java.awt.Frame parent, DesktopApplication1 app) {
        //super(parent);
        initComponents();
        initPanel();
	this.app = app;
	app.hide(app.getApplication().getMainView());
        //getRootPane().setDefaultButton(closeButton);
    }

    		protected void processWindowEvent(WindowEvent e) {

			if (e.getID() == WindowEvent.WINDOW_CLOSING) {


                            ApplicationContext ctx=
  				Application.getInstance().getContext();

                            Object[] options = {ctx.getResourceMap().getString("dialogConfirm.ok"),
                                                ctx.getResourceMap().getString("dialogConfirm.cancel")};


                            int exit = JOptionPane.showOptionDialog(this,
						ctx.getResourceMap().getString("dialogConfirm.message"),
                                                ctx.getResourceMap().getString("dialogConfirm.title"),
                                               JOptionPane.YES_NO_OPTION,
                                               JOptionPane.QUESTION_MESSAGE,
                                               null,
                                               options,
                                               options[0]);
				if (exit == JOptionPane.YES_OPTION) {
					app.exit();
				}		    

			}

		}

    public void initPanel(){
        try{
        Map<Integer,Producto> prodMap = Catalog.getProductListByCategory(DesktopApplication1.lang_id, 1);
        prods= new ArrayList(prodMap.values());
        cantPag = prods.size()/6+(((prods.size()%6) != 0)?1:0);
        currPage=1;
        int cantP = (cantPag==0)?1:cantPag;
        jLabel26.setText(((Integer)currPage).toString()+"/"+((Integer)cantP).toString());
        setPanels(1);
        }catch(Exception e){
            System.out.println(e);
        }
    }

    @Action
    public void nextPage() {
        currPage++;
        setPanels(currPage);
//        int cantP = (cantPag==0)?1:cantPag;
        jLabel26.setText(((Integer)currPage).toString()+"/"+((Integer)cantPag).toString());
        jButton2.setEnabled(true);

        if(currPage==cantPag){
            jButton1.setEnabled(false);
        }
    }

    @Action
    public void prevPage() {
        currPage--;
        setPanels(currPage);
//        int cantP = (cantPag==0)?1:cantPag;
        jLabel26.setText(((Integer)currPage).toString()+"/"+((Integer)cantPag).toString());
        jButton1.setEnabled(true);

        if(currPage==1){
            jButton2.setEnabled(false);
        }
    }

    @Action
    public void showSearch() {
        
        String query = jTextField1.getText();

         ApplicationContext ctx=Application.getInstance().getContext();

        if(query.equalsIgnoreCase("") ||
                query.equalsIgnoreCase(ctx.getResourceMap().getString("jTextField1.message"))){

            jTextField1.setText(ctx.getResourceMap().getString("jTextField1.message"));

            return;
        }

        try{
            Map<Integer,Producto> prodMap = Catalog.getProductListByName(query);
            prods= new ArrayList(prodMap.values());
            cantPag = prods.size()/6+(((prods.size()%6) != 0)?1:0);
            currPage=1;
            int cantP = (cantPag==0)?1:cantPag;
            jLabel26.setText(((Integer)currPage).toString()+"/"+((Integer)cantP).toString());
            setPanels(1);
            jButton2.setEnabled(false);
            if(cantPag>1){
                jButton1.setEnabled(true);
            }else{
                jButton1.setEnabled(false);
            }
        }catch(Exception e){
            System.out.println(e);
        }
    }

    public void getCategories(javax.swing.tree.DefaultMutableTreeNode root){
        
        DefaultMutableTreeNode item;

        try{
        Map<Integer,Categoria> cats = Catalog.getCategoryList(DesktopApplication1.lang_id);
        categorias= new ArrayList(cats.values());

        for(Categoria cat:categorias){
            item = new javax.swing.tree.DefaultMutableTreeNode(cat.getName());
            addSubCat(item, cat.getId());
            root.add(item);
        }

        }catch(Exception e){
            System.out.println(e);
        }

    }

    public void addSubCat(javax.swing.tree.DefaultMutableTreeNode cat, int cat_id){
        DefaultMutableTreeNode item;

        try{
        Map<Integer,SubCategoria> subCats = Catalog.getSubCategoryList(DesktopApplication1.lang_id, cat_id);
        subCategorias= new ArrayList(subCats.values());

        for(SubCategoria subCat : subCategorias){
            item = new javax.swing.tree.DefaultMutableTreeNode(subCat.getName());
            cat.add(item);
        }
        }catch(Exception e){
            System.out.println(e);
        }
    }

     public void showDetail(int prod_id){
        JFrame prodDetail = new ProdDetail(prod_id);
        DesktopApplication1.getApplication().show(prodDetail);
    }

    @Action
    public void accountInformation() {

        ApplicationContext ctx=Application.getInstance().getContext();

	if(user == null){
		JOptionPane.showMessageDialog(null, ctx.getResourceMap().getString("accountDialog.notLogged"), "Error", JOptionPane.ERROR_MESSAGE);
	}
	else{
	    PanelAccountInformation panelAccountInformation = new PanelAccountInformation();
	    panelAccountInformation.setVisible(true);
	    contenido.removeAll();
	    contenido.setLayout(new BorderLayout());
	    contenido.add(panelAccountInformation,BorderLayout.CENTER);
	    panelAccountInformation.updateUI();
	    contenido.updateUI();
	}
    }

    @Action
    public void signOut() {
        contenido.removeAll();
        contenido.updateUI();
        
	ApplicationContext ctx=Application.getInstance().getContext();

	if(user == null){
		JOptionPane.showMessageDialog(null, ctx.getResourceMap().getString("accountDialog.notLogged"), "Error", JOptionPane.ERROR_MESSAGE);
	}
	else{
            Object[] args={user.getUserName()};
            MessageFormat form = new MessageFormat(ctx.getResourceMap().getString("accountDialog.logged"));
            JOptionPane.showMessageDialog(null,form.format(args) , "Info", JOptionPane.PLAIN_MESSAGE);

            user=null;

            status.setText(ctx.getResourceMap().getString("accountDialog.notLogged"));
            userPanel.updateUI();
        }

    }

    @Action
    public void changePassword() {

	ApplicationContext ctx=Application.getInstance().getContext();

	if(user == null){
		JOptionPane.showMessageDialog(null, ctx.getResourceMap().getString("accountDialog.notLogged"), "Error", JOptionPane.ERROR_MESSAGE);
	}
	else{
	    PanelChangePass panelChangePass = new PanelChangePass();
	    panelChangePass.setVisible(true);
	    contenido.removeAll();
	    contenido.setLayout(new BorderLayout());
	    contenido.add(panelChangePass,BorderLayout.CENTER);
	    panelChangePass.updateUI();
	    contenido.updateUI();
	}
    }

    @Action
    public void modifyAccount() {

    	ApplicationContext ctx=Application.getInstance().getContext();

	if(user == null){
		JOptionPane.showMessageDialog(null, ctx.getResourceMap().getString("accountDialog.notLogged"), "Error", JOptionPane.ERROR_MESSAGE);
	}
	else{
	    PanelModifyAccount panelModifyAccount = new PanelModifyAccount();
	    panelModifyAccount.setVisible(true);
	    contenido.removeAll();
	    contenido.setLayout(new BorderLayout());
	    contenido.add(panelModifyAccount,BorderLayout.CENTER);
	    panelModifyAccount.updateUI();
	    contenido.updateUI();
	}

    }

    @Action
    public void createAccount() {

    	PanelCreateAccount panelCreateAccount = new PanelCreateAccount();
	panelCreateAccount.setVisible(true);
	contenido.removeAll();
        contenido.setLayout(new BorderLayout());
        contenido.add(panelCreateAccount,BorderLayout.CENTER);
        panelCreateAccount.updateUI();
        contenido.updateUI();

    }



    @Action
    public void signIn() {

        ApplicationContext ctx=Application.getInstance().getContext();

	if(user != null){
	    Object[] args={user.getUserName()};
            MessageFormat form = new MessageFormat(ctx.getResourceMap().getString("accountDialog.alreadyLogged"));
            JOptionPane.showMessageDialog(null,form.format(args) , "Error", JOptionPane.PLAIN_MESSAGE);
	}
	else{
	    PanelSignIn panelSignIn = new PanelSignIn();
	    panelSignIn.setVisible(true);
	    contenido.removeAll();
	    contenido.setLayout(new BorderLayout());
	    contenido.add(panelSignIn,BorderLayout.CENTER);
	    panelSignIn.updateUI();
	    contenido.updateUI();
	}
    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        prodPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        categoryTree = new javax.swing.JTree();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        titlePanel1 = new javax.swing.JLabel();
        picPanel1 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        titlePanel2 = new javax.swing.JLabel();
        picPanel2 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        titlePanel3 = new javax.swing.JLabel();
        picPanel3 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        titlePanel4 = new javax.swing.JLabel();
        picPanel4 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        titlePanel5 = new javax.swing.JLabel();
        picPanel5 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        titlePanel6 = new javax.swing.JLabel();
        picPanel6 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        userPanel = new javax.swing.JPanel();
        contenido = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        status = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopapplication1.DesktopApplication1.class).getContext().getResourceMap(mainWin.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N
        setResizable(false);

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        prodPanel.setName("prodPanel"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("Categories");
        categoryTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        categoryTree.setName("categoryTree"); // NOI18N
        getCategories(treeNode1);
        categoryTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        categoryTree.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                categoryTreeMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(categoryTree);

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new GridLayout(4,4));

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel2MouseClicked(evt);
            }
        });

        titlePanel1.setText(resourceMap.getString("titlePanel1.text")); // NOI18N
        titlePanel1.setName("titlePanel1"); // NOI18N

        picPanel1.setText(resourceMap.getString("picPanel1.text")); // NOI18N
        picPanel1.setName("picPanel1"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel13.setText(resourceMap.getString("rankLabel1.text")); // NOI18N
        jLabel13.setName("rankLabel1"); // NOI18N

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(titlePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(picPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel19))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel13)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titlePanel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(picPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel19)))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel3MouseClicked(evt);
            }
        });

        titlePanel2.setText(resourceMap.getString("titlePanel2.text")); // NOI18N
        titlePanel2.setName("titlePanel2"); // NOI18N

        picPanel2.setText(resourceMap.getString("picPanel2.text")); // NOI18N
        picPanel2.setName("picPanel2"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel14.setText(resourceMap.getString("rankLabel2.text")); // NOI18N
        jLabel14.setName("rankLabel2"); // NOI18N

        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(titlePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(picPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel20))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel14)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titlePanel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(picPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel20)))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel4MouseClicked(evt);
            }
        });

        titlePanel3.setText(resourceMap.getString("titlePanel3.text")); // NOI18N
        titlePanel3.setName("titlePanel3"); // NOI18N

        picPanel3.setText(resourceMap.getString("picPanel3.text")); // NOI18N
        picPanel3.setName("picPanel3"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel15.setText(resourceMap.getString("rankLabel3.text")); // NOI18N
        jLabel15.setName("rankLabel3"); // NOI18N

        jLabel21.setText(resourceMap.getString("jLabel21.text")); // NOI18N
        jLabel21.setName("jLabel21"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(titlePanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(picPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel21))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel15)))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titlePanel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(picPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel21)))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel5.setName("jPanel5"); // NOI18N
        jPanel5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel5MouseClicked(evt);
            }
        });

        titlePanel4.setText(resourceMap.getString("titlePanel4.text")); // NOI18N
        titlePanel4.setName("titlePanel4"); // NOI18N

        picPanel4.setText(resourceMap.getString("picPanel4.text")); // NOI18N
        picPanel4.setName("picPanel4"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel16.setText(resourceMap.getString("rankLabel4.text")); // NOI18N
        jLabel16.setName("rankLabel4"); // NOI18N

        jLabel22.setText(resourceMap.getString("jLabel22.text")); // NOI18N
        jLabel22.setName("jLabel22"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(titlePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(picPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel22))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel16)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titlePanel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(picPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel22)))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel6.setName("jPanel6"); // NOI18N
        jPanel6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel6MouseClicked(evt);
            }
        });

        titlePanel5.setText(resourceMap.getString("titlePanel5.text")); // NOI18N
        titlePanel5.setName("titlePanel5"); // NOI18N

        picPanel5.setText(resourceMap.getString("picPanel5.text")); // NOI18N
        picPanel5.setName("picPanel5"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jLabel17.setText(resourceMap.getString("rankLabel5.text")); // NOI18N
        jLabel17.setName("rankLabel5"); // NOI18N

        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(titlePanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(picPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel23))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel17)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titlePanel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(picPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel23)))
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel7.setName("jPanel7"); // NOI18N
        jPanel7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel7MouseClicked(evt);
            }
        });

        titlePanel6.setText(resourceMap.getString("titlePanel6.text")); // NOI18N
        titlePanel6.setName("titlePanel6"); // NOI18N

        picPanel6.setText(resourceMap.getString("picPanel6.text")); // NOI18N
        picPanel6.setName("picPanel6"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jLabel18.setText(resourceMap.getString("rankLabel6.text")); // NOI18N
        jLabel18.setName("rankLabel6"); // NOI18N

        jLabel24.setText(resourceMap.getString("jLabel24.text")); // NOI18N
        jLabel24.setName("jLabel24"); // NOI18N

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(titlePanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(picPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel24))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel18)))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titlePanel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(picPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel24)))
        );

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(desktopapplication1.DesktopApplication1.class).getContext().getActionMap(mainWin.class, this);
        jButton1.setAction(actionMap.get("nextPage")); // NOI18N
        jButton1.setMnemonic('X');
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.setNextFocusableComponent(jButton3);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setAction(actionMap.get("prevPage")); // NOI18N
        jButton2.setMnemonic('E');
        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setEnabled(false);
        jButton2.setName("jButton2"); // NOI18N
        jButton2.setNextFocusableComponent(jButton1);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel25.setText(resourceMap.getString("jLabel25.text")); // NOI18N
        jLabel25.setName("jLabel25"); // NOI18N

        jLabel26.setText(resourceMap.getString("jLabel26.text")); // NOI18N
        jLabel26.setName("jLabel26"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE))
                .addGap(12, 12, 12)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(28, 28, 28)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton2))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel25)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel26)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel25)
                            .addComponent(jLabel26))
                        .addGap(28, 28, 28)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton1))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGap(18, 18, 18)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGap(18, 18, 18)
                            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(21, Short.MAX_VALUE))
        );

        jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N
        jTextField1.setAction(actionMap.get("showSearch")); // NOI18N
        jTextField1.setName("jTextField1"); // NOI18N
        jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextField1KeyReleased(evt);
            }
        });

        jButton3.setAction(actionMap.get("showSearch")); // NOI18N
        jButton3.setMnemonic('R');
        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N
        jButton3.setNextFocusableComponent(jButton2);

        javax.swing.GroupLayout prodPanelLayout = new javax.swing.GroupLayout(prodPanel);
        prodPanel.setLayout(prodPanelLayout);
        prodPanelLayout.setHorizontalGroup(
            prodPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(prodPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(prodPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton3)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 893, Short.MAX_VALUE)
                .addContainerGap())
        );
        prodPanelLayout.setVerticalGroup(
            prodPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, prodPanelLayout.createSequentialGroup()
                .addGroup(prodPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(prodPanelLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, prodPanelLayout.createSequentialGroup()
                        .addContainerGap(42, Short.MAX_VALUE)
                        .addComponent(jTextField1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 592, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("prodPanel.TabConstraints.tabTitle"), prodPanel); // NOI18N

        userPanel.setName("userPanel"); // NOI18N

        contenido.setName("contenido"); // NOI18N

        javax.swing.GroupLayout contenidoLayout = new javax.swing.GroupLayout(contenido);
        contenido.setLayout(contenidoLayout);
        contenidoLayout.setHorizontalGroup(
            contenidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 582, Short.MAX_VALUE)
        );
        contenidoLayout.setVerticalGroup(
            contenidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 444, Short.MAX_VALUE)
        );

        jButton4.setAction(actionMap.get("createAccount")); // NOI18N
        jButton4.setMnemonic('C');
        jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
        jButton4.setName("jButton4"); // NOI18N

        jButton5.setAction(actionMap.get("signIn")); // NOI18N
        jButton5.setMnemonic('N');
        jButton5.setText(resourceMap.getString("jButton5.text")); // NOI18N
        jButton5.setName("jButton5"); // NOI18N

        jButton6.setAction(actionMap.get("signOut")); // NOI18N
        jButton6.setMnemonic('O');
        jButton6.setText(resourceMap.getString("jButton6.text")); // NOI18N
        jButton6.setName("jButton6"); // NOI18N

        jButton7.setAction(actionMap.get("changePassword")); // NOI18N
        jButton7.setMnemonic('E');
        jButton7.setText(resourceMap.getString("jButton7.text")); // NOI18N
        jButton7.setName("jButton7"); // NOI18N

        jButton8.setAction(actionMap.get("accountInformation")); // NOI18N
        jButton8.setMnemonic('I');
        jButton8.setText(resourceMap.getString("jButton8.text")); // NOI18N
        jButton8.setName("jButton8"); // NOI18N

        jButton9.setAction(actionMap.get("modifyAccount")); // NOI18N
        jButton9.setMnemonic('M');
        jButton9.setText(resourceMap.getString("jButton9.text")); // NOI18N
        jButton9.setName("jButton9"); // NOI18N

        status.setText(resourceMap.getString("status.text")); // NOI18N
        status.setName("status"); // NOI18N

        javax.swing.GroupLayout userPanelLayout = new javax.swing.GroupLayout(userPanel);
        userPanel.setLayout(userPanelLayout);
        userPanelLayout.setHorizontalGroup(
            userPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(userPanelLayout.createSequentialGroup()
                .addGap(41, 41, 41)
                .addGroup(userPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(status, javax.swing.GroupLayout.PREFERRED_SIZE, 298, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(userPanelLayout.createSequentialGroup()
                        .addGroup(userPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton4)
                            .addComponent(jButton5)
                            .addComponent(jButton6)
                            .addComponent(jButton7)
                            .addComponent(jButton8)
                            .addComponent(jButton9))
                        .addGap(318, 318, 318)
                        .addComponent(contenido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        userPanelLayout.setVerticalGroup(
            userPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(userPanelLayout.createSequentialGroup()
                .addGroup(userPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(userPanelLayout.createSequentialGroup()
                        .addGap(109, 109, 109)
                        .addComponent(contenido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(userPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(status, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(86, 86, 86)
                        .addComponent(jButton4)
                        .addGap(18, 18, 18)
                        .addComponent(jButton5)
                        .addGap(18, 18, 18)
                        .addComponent(jButton6)
                        .addGap(18, 18, 18)
                        .addComponent(jButton7)
                        .addGap(18, 18, 18)
                        .addComponent(jButton8)
                        .addGap(18, 18, 18)
                        .addComponent(jButton9)))
                .addContainerGap(167, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("userPanel.TabConstraints.tabTitle"), userPanel); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1080, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 748, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void categoryTreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_categoryTreeMouseClicked

        int cat_id;
        
        try{
            int level = ((javax.swing.tree.DefaultMutableTreeNode)categoryTree.getLastSelectedPathComponent()).getLevel();

            if(level==1){
                //es categoria
                cat_id = getCatId(categoryTree.getLastSelectedPathComponent().toString());
                //obtener los productos y guardarlos en un arreglo
                Map<Integer,Producto> prodMap = Catalog.getProductListByCategory(DesktopApplication1.lang_id, cat_id);
                prods= new ArrayList(prodMap.values());
                cantPag = prods.size()/6+(((prods.size()%6) != 0)?1:0);
                currPage=1;
                int cantP = (cantPag==0)?1:cantPag;
                jLabel26.setText(((Integer)currPage).toString()+"/"+((Integer)cantP).toString());
                //rellenar los panels
                setPanels(1);
                //activar/desactivar botones
                jButton2.setEnabled(false);
                if(cantPag<2){
                    jButton1.setEnabled(false);
                }else{
                    jButton1.setEnabled(true);
                }
            }else if(level ==2){
                //es subcategoria
                String parent = ((javax.swing.tree.DefaultMutableTreeNode)categoryTree.getLastSelectedPathComponent()).getParent().toString();
                cat_id=getCatId(parent);
                Map<Integer,SubCategoria> subCats = Catalog.getSubCategoryList(DesktopApplication1.lang_id, cat_id);
                subCategorias= new ArrayList(subCats.values());

                int sub_cat_id = getSubCatId(categoryTree.getLastSelectedPathComponent().toString());
                Map<Integer,Producto> prodMap = Catalog.getProductListBySubCategory(DesktopApplication1.lang_id, cat_id, sub_cat_id);
                prods= new ArrayList(prodMap.values());
                cantPag = prods.size()/6+(((prods.size()%6) != 0)?1:0);
                currPage=1;
                int cantP = (cantPag==0)?1:cantPag;
                jLabel26.setText(((Integer)currPage).toString()+"/"+((Integer)cantP).toString());
                setPanels(1);
                jButton2.setEnabled(false);
                if(cantPag<2){
                    jButton1.setEnabled(false);
                }else{
                    jButton1.setEnabled(true);
                }
           }
        }catch(Exception e){
            System.out.println(e);
        }

    }//GEN-LAST:event_categoryTreeMouseClicked

    public void setPanels(int pageRecv){
        int cant = prods.size();
        //indice para ingresar a la lista de productos
        int page = pageRecv-1;

        try{
        if((page*6+0)<cant){
            titlePanel1.setText(prods.get(page*6+0).getName());
            picPanel1.setIcon(new ImageIcon(DesktopApplication1.getScaledImage((new ImageIcon(new URL(prods.get(page*6+0).getImage()))).getImage(),180,240)));
            picPanel1.setText("");
            jLabel13.setText(((Double)prods.get(page*6+0).getRank()).toString());
            jLabel19.setText(((Double)prods.get(page*6+0).getPrice()).toString());
        }else{
            titlePanel1.setText("-");
            picPanel1.setIcon(null);
            jLabel13.setText("");
            jLabel19.setText("");
        }
        if((page*6+1)<cant){
            titlePanel2.setText(prods.get(page*6+1).getName());
            picPanel2.setIcon(new ImageIcon(DesktopApplication1.getScaledImage((new ImageIcon(new URL(prods.get(page*6+1).getImage()))).getImage(),180,240)));
            picPanel2.setText("");
            jLabel14.setText(((Double)prods.get(page*6+1).getRank()).toString());
            jLabel20.setText(((Double)prods.get(page*6+1).getPrice()).toString());
        }else{
            titlePanel2.setText("-");
            picPanel2.setIcon(null);
            jLabel14.setText("");
            jLabel20.setText("");
        }
        if((page*6+2)<cant){
            titlePanel3.setText(prods.get(page*6+2).getName());
            picPanel3.setIcon(new ImageIcon(DesktopApplication1.getScaledImage((new ImageIcon(new URL(prods.get(page*6+2).getImage()))).getImage(),180,240)));
            picPanel3.setText("");
            jLabel15.setText(((Double)prods.get(page*6+2).getRank()).toString());
            jLabel21.setText(((Double)prods.get(page*6+2).getPrice()).toString());
        }else{
            titlePanel3.setText("-");
            picPanel3.setIcon(null);
            jLabel15.setText("");
            jLabel21.setText("");
        }
        if((page*6+3)<cant){
            titlePanel4.setText(prods.get(page*6+3).getName());
            picPanel4.setIcon(new ImageIcon(DesktopApplication1.getScaledImage((new ImageIcon(new URL(prods.get(page*6+3).getImage()))).getImage(),180,240)));
            picPanel4.setText("");
            jLabel16.setText(((Double)prods.get(page*6+3).getRank()).toString());
            jLabel22.setText(((Double)prods.get(page*6+3).getPrice()).toString());
        }
        else{
            titlePanel4.setText("-");
            picPanel4.setIcon(null);
            jLabel16.setText("");
            jLabel22.setText("");
        }
        if((page*6+4)<cant){
            titlePanel5.setText(prods.get(page*6+4).getName());
            picPanel5.setIcon(new ImageIcon(DesktopApplication1.getScaledImage((new ImageIcon(new URL(prods.get(page*6+4).getImage()))).getImage(),180,240)));
            picPanel5.setText("");
            jLabel17.setText(((Double)prods.get(page*6+4).getRank()).toString());
            jLabel23.setText(((Double)prods.get(page*6+4).getPrice()).toString());
        }else{
            titlePanel5.setText("-");
            picPanel5.setIcon(null);
            jLabel17.setText("");
            jLabel23.setText("");
        }
        if((page*6+5)<cant){
            titlePanel6.setText(prods.get(page*6+5).getName());
            picPanel6.setIcon(new ImageIcon(DesktopApplication1.getScaledImage((new ImageIcon(new URL(prods.get(page*6+5).getImage()))).getImage(),180,240)));
            picPanel6.setText("");
            jLabel18.setText(((Double)prods.get(page*6+5).getRank()).toString());
            jLabel24.setText(((Double)prods.get(page*6+5).getPrice()).toString());
        }
        else{
            titlePanel6.setText("-");
            picPanel6.setIcon(null);
            jLabel18.setText("");
            jLabel24.setText("");
        }
        }catch(Exception e){
            System.out.println(e);
        }
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jPanel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel2MouseClicked
        if(((currPage-1)*6) < prods.size()){
            showDetail(prods.get((currPage-1)*6).getId());
        }
    }//GEN-LAST:event_jPanel2MouseClicked

    private void jPanel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel3MouseClicked
        if(((currPage-1)*6+1) < prods.size()){
            showDetail(prods.get((currPage-1)*6+1).getId());
        }
    }//GEN-LAST:event_jPanel3MouseClicked

    private void jPanel4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel4MouseClicked
        if(((currPage-1)*6+2) < prods.size()){
            showDetail(prods.get((currPage-1)*6+2).getId());
        }
    }//GEN-LAST:event_jPanel4MouseClicked

    private void jPanel5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel5MouseClicked
        if(((currPage-1)*6+3) < prods.size()){
            showDetail(prods.get((currPage-1)*6+3).getId());
        }
    }//GEN-LAST:event_jPanel5MouseClicked

    private void jPanel6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel6MouseClicked
        if(((currPage-1)*6+4) < prods.size()){
            showDetail(prods.get((currPage-1)*6+4).getId());
        }
    }//GEN-LAST:event_jPanel6MouseClicked

    private void jPanel7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel7MouseClicked
        if(((currPage-1)*6+5) < prods.size()){
            showDetail(prods.get((currPage-1)*6+5).getId());
        }
    }//GEN-LAST:event_jPanel7MouseClicked

    private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyReleased
        if(! jTextField1.getText().equalsIgnoreCase("")){
            showSearch();
        }
    }//GEN-LAST:event_jTextField1KeyReleased

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new mainWin().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTree categoryTree;
    private javax.swing.JPanel contenido;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JLabel picPanel1;
    private javax.swing.JLabel picPanel2;
    private javax.swing.JLabel picPanel3;
    private javax.swing.JLabel picPanel4;
    private javax.swing.JLabel picPanel5;
    private javax.swing.JLabel picPanel6;
    private javax.swing.JPanel prodPanel;
    public static javax.swing.JLabel status;
    private javax.swing.JLabel titlePanel1;
    private javax.swing.JLabel titlePanel2;
    private javax.swing.JLabel titlePanel3;
    private javax.swing.JLabel titlePanel4;
    private javax.swing.JLabel titlePanel5;
    private javax.swing.JLabel titlePanel6;
    public static javax.swing.JPanel userPanel;
    // End of variables declaration//GEN-END:variables

}
